package com.xjust.controller;

import com.xjust.pojo.DrugInfo;
import com.xjust.pojo.Register;
import com.xjust.pojo.Result;
import com.xjust.pojo.ResultBean;
import com.xjust.service.PharmacyService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/pharmacy")
public class PharmacyController {
    @Autowired
    private PharmacyService pharmacyService;
    //获取发药患者信息
    @GetMapping("/getMediPatients")
    public ResultBean getMediPatients(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "5") Integer pageSize,
            String caseNumber,
            String realName){
        return pharmacyService.getMediPatients(page,pageSize,caseNumber,realName);
    }
    //获取患者药品信息
    @GetMapping("/getMediDrug")
    public Result getMediDrug(@RequestParam String caseNumber){
        return pharmacyService.getMediDrug(caseNumber);
    }
    //改变药品状态
    @PutMapping("/issueMedication")
    public Result putIssueMedication(@RequestParam("drug_id") Integer drugId,@RequestParam("case_number") String caseNumber) {
        System.out.println("Drug ID=" + drugId);
        System.out.println("Case Number= " + caseNumber);
        return pharmacyService.putIssueMedication(drugId,caseNumber);
    }
}
